import com.ynny.mapper.StudentMapper;
import com.ynny.pojo.Student;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Test;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

public class test {

    @Test
    public void test() throws IOException {

        // 需要 sqlSession sql会话
        InputStream resourceAsStream =
                Resources.getResourceAsStream("mybatis-config.xml");
        SqlSessionFactory sessionFactory =
                new SqlSessionFactoryBuilder().build(resourceAsStream);

        //开启会话
        SqlSession sqlSession =
                sessionFactory.openSession(true);

        //获取接口
        StudentMapper studentMapper = sqlSession.getMapper(StudentMapper.class);

          Student student = new Student();
//        student.setNumber("11111");
//        student.setName("张三");
//        student.setPassword("123456");
//        student.setGrade("2019");
//        student.setClbum("计算机");
//        student.setGender("男");
//        student.setType("学生");
//        int update = studentMapper.updateBynumber(student);
//        System.out.println(update);

//        List<Student> students = studentMapper.selectByType("学生");
//        for (Student student1 : students) {
//            System.out.println(student1);
//        }


        int i = studentMapper.deleteByNumber("11111");
        System.out.println(i);
    }
}
